
package cn.tang.tframe.sdm.aop.wrapper;

import cn.tang.tframe.sdm.aop.WrapAspectUtil;
import cn.tang.tframe.sdm.aop.WrapException;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.reflect.MethodSignature;

/**
 * Created by tanghc on 17/1/18.
 */
public class CatExceptionAopServiceWrapper extends CommonAopServiceWrapper {

	protected Object returnWhenException(ProceedingJoinPoint pjp, Exception e)
		throws Exception {

		if (WrapAspectUtil.hasAnnotation(
			pjp.getTarget().getClass(),
			((MethodSignature) pjp.getSignature()).getMethod(),
			WrapException.class)) {
			return WrapAspectUtil.exceptionToBaseResult(e);
		}
		throw e;
	}
}
